package com.syni.mdd.sjb.common.datatreaure.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.syni.mdd.sjb.common.component.mybatis.dxshapp.entity.PcBankData;
import com.syni.mdd.sjb.common.component.mybatis.dxshapp.entity.customBo.BankBranchBo;
import com.syni.mdd.sjb.common.component.mybatis.dxshapp.mapper.PcBankDataMapper;
import com.syni.mdd.sjb.common.component.utils.common.utils.BeanUtils;
import com.syni.mdd.sjb.common.datatreaure.service.PcBankDataService;
import com.syni.mdd.sjb.common.datatreaure.entity.vo.rp.userChannel.BankBranchRpVo;
import com.syni.mdd.sjb.common.datatreaure.entity.vo.rq.userChannel.CityCodeVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author lcc
 * @since 2020-04-30
 */
@Service
public class PcBankDataServiceImpl extends ServiceImpl<PcBankDataMapper, PcBankData> implements PcBankDataService {

    @Autowired
    PcBankDataMapper pcBankDataMapper;

    @Override
    public List<PcBankData> getList() {
        List<PcBankData> pcBankData = pcBankDataMapper.selectList(new QueryWrapper<>());
        return pcBankData;
    }

    @Override
    public List<PcBankData> findByCityId(CityCodeVo cityCodeVo) {
        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.eq(PcBankData.CITY_ID, cityCodeVo.getCodeNum());
        List<PcBankData> bankDataList= pcBankDataMapper.selectList(queryWrapper);
        return bankDataList;
    }

    @Override
    public List<BankBranchRpVo> getBankBranch(CityCodeVo cityCodeVo) {
        List<BankBranchBo> bankBranchBos = pcBankDataMapper.getBankBranch(cityCodeVo.getCodeNum(),cityCodeVo.getBankName());
        List<BankBranchRpVo> bankBranchRpVos = BeanUtils.copyList(bankBranchBos,BankBranchRpVo.class);
        return bankBranchRpVos;
    }
}
